require 'savon'

def testCS
  client = Savon.client(wsdl: "http://soadv.ea.intropro.com/soa-infra/services/default/BPMTest5/ProcessPAD.service?WSDL", namespace: "http://xmlns.oracle.com/bpm/bpmobject/Module/BusinessObject")

  message = {"tns:BusinessObject"=> {"tns:material"=>medias}}
  

  response = client.call(:start, message: message)
  
end

  def medias 
    ['B000002514M3', 'B000002514F3']
    ['B000002514M3', 'B000002514F3', 'B000002516M3', 'B000002516F3', 'B000002517M3', 'B000002517F3', 'B000002518M3', 'B000002518F3', 'B000002519M3', 'B000002519F3', 'B000002524M3']
  end

  
def testPTP
  client = Savon.client(wsdl: "http://soadv.ea.intropro.com/soa-infra/services/Content/ProcessTitlePackage/ProcessTitlePackageService?WSDL", namespace: "http://directv.com/Content/Data/ContentMetadata")

  session_id = "CAmeriva_HBO_20131227170852711"

  bmid_original = "B000288518"
  bmid = "B000013109"

  letter1 = "M"
  mid1_original = bmid_original + letter1 + "0"
  mid1_house = bmid + letter1 + "0"
  mid1_bc = bmid + letter1 + "3"
  media1_cat = "movie_" + bmid_original + letter1 + "0"

  letter2 = "F"
  mid2_original = bmid_original + letter2 + "0"
  mid2_house = bmid + letter2 + "0"
  mid2_bc = bmid + letter2 + "3"
  media2_cat = "movie_" + bmid_original + letter2 + "0"

  
  message = {"tns:MetadataProperties"=> {"MetadataProperty"=>[
                                         {"Name"=>"GeoID", "Category"=>"session", "Value"=>"PA"},
                                         {"Name"=>"SessionID", "Category"=>"session", "Value"=>session_id},
                                        
                                         {"Name"=>"BaseMaterialID", "Category"=>"package", "Value"=>bmid},
#                                          {"Name"=>"ProviderIsTrusted", "Category"=>"package", "Value"=>"true"},
#                                          {"Name"=>"CheckListApproved", "Category"=>"package", "Value"=>""},
#                                          {"Name"=>"Provider", "Category"=>"package", "Value"=>"TVNSDPPV"},
#                                          {"Name"=>"Provider_ID", "Category"=>"package", "Value"=>"TVN.com"},
                                        
#                                          {"Name"=>"DelayPublish", "Category"=>"title", "Value"=>""},
                                         {"Name"=>"Licensing_Window_Start", "Category"=>"title", "Value"=>"2011-10-25T00:00:00"},
                                         {"Name"=>"Licensing_Window_End", "Category"=>"title", "Value"=>"2013-12-24T23:59:59"},
                                         {"Name"=>"RatingID", "Category"=>"title", "Value"=>""},
                                         {"Name"=>"Title", "Category"=>"title", "Value"=>"Captain America: The First Avenger"},
                                         {"Name"=>"Asset_Class", "Category"=>"title", "Value"=>"title"},
                                         {"Name"=>"Product", "Category"=>"title", "Value"=>"MOD"},
                                         {"Name"=>"Service_Category", "Category"=>"title", "Value"=>"PMTHD0_599_PPV"},
                                         {"Name"=>"Guide_Category", "Category"=>"title", "Value"=>"Action/Adventure"},
                                        
                                         {"Name"=>"MaterialId", "Category"=>media1_cat, "Value"=>mid1_original},
                                         {"Name"=>"MaterialID_house", "Category"=>media1_cat, "Value"=>mid1_house},
                                         {"Name"=>"MaterialID_bc", "Category"=>media1_cat, "Value"=>mid1_bc},
#                                          {"Name"=>"AssetType", "Category"=>media1_cat, "Value"=>"movie"},
                                         {"Name"=>"EncryptionTypeID", "Category"=>media1_cat, "Value"=>"3"},

                                         {"Name"=>"EncryptionTypeName", "Category"=>media1_cat, "Value"=>"AES"},
                                         {"Name"=>"DistributionDestination", "Category"=>media1_cat, "Value"=>""},
                                         {"Name"=>"HideContentFromGuide", "Category"=>media1_cat, "Value"=>"false"},
#                                          {"Name"=>"ContentType", "Category"=>media1_cat, "Value"=>"BBV"},
#                                          {"Name"=>"AudioStreams", "Category"=>media1_cat, "Value"=>""},
#                                          {"Name"=>"FEDDate", "Category"=>"", "Value"=>""},
#                                          {"Name"=>"MEDDate", "Category"=>"", "Value"=>""},
#                                          {"Name"=>"STBVersion", "Category"=>"", "Value"=>""},
                                        
                                         {"Name"=>"FileLocationOriginal", "Category"=>media1_cat + "_house", "Value"=>"/opt/DIST/CableLabsFiles/dev_provider/original/#{session_id}/#{mid1_original}/#{mid1_original}.ts"},
                                         {"Name"=>"FileLocationBC", "Category"=>media1_cat + "_house", "Value"=>"/opt/DIST/CableLabsFiles/dev_provider/bc/movie/#{Time.now.year}_#{Time.now.month}/#{bmid}/#{mid1_bc}/#{mid1_bc}.ats"},
                                         {"Name"=>"FileLocationHouse", "Category"=>media1_cat + "_house", "Value"=>"/opt/DIST/CableLabsFiles/dev_provider/house/movie/#{Time.now.year}_#{Time.now.month}/#{mid1_house}/#{mid1_house}.ts"},
#                                          {"Name"=>"ScreenFormat", "Category"=>media1_cat + "_house", "Value"=>"HD"},
#                                          {"Name"=>"DurInSec", "Category"=>media1_cat + "_house", "Value"=>"5520"},
#                                          {"Name"=>"IPPVFlag", "Category"=>media1_cat + "_house", "Value"=>"true"},
#                                          {"Name"=>"CAFormApprovalType", "Category"=>media1_cat + "_house", "Value"=>"auto"},
                                         {"Name"=>"AudioType", "Category"=>media1_cat + "_house", "Value"=>"AC3"},
                                        
                                                              
                                         {"Name"=>"MaterialId", "Category"=>media2_cat, "Value"=>mid2_original},
                                         {"Name"=>"MaterialID_house", "Category"=>media2_cat, "Value"=>mid2_house},
                                         {"Name"=>"MaterialID_bc", "Category"=>media2_cat, "Value"=>mid2_bc},
#                                          {"Name"=>"AssetType", "Category"=>media2_cat, "Value"=>"movie"},
                                         {"Name"=>"EncryptionTypeID", "Category"=>media2_cat, "Value"=>"3"},
                                         {"Name"=>"EncryptionTypeName", "Category"=>media2_cat, "Value"=>"AES"},
                                         {"Name"=>"DistributionDestination", "Category"=>media2_cat, "Value"=>""},
                                         {"Name"=>"HideContentFromGuide", "Category"=>media2_cat, "Value"=>"false"},
#                                          {"Name"=>"ContentType", "Category"=>media2_cat, "Value"=>"BBV"},
#                                          {"Name"=>"AudioStreams", "Category"=>media2_cat, "Value"=>""},
#                                          {"Name"=>"FEDDate", "Category"=>"", "Value"=>""},
#                                          {"Name"=>"MEDDate", "Category"=>"", "Value"=>""},
#                                          {"Name"=>"STBVersion", "Category"=>"", "Value"=>""},
                                        
                                         {"Name"=>"FileLocationOriginal", "Category"=>media2_cat + "_house", "Value"=>"/opt/DIST/CableLabsFiles/dev_provider/original/#{session_id}/#{mid2_original}/#{mid2_original}.ts"},
                                         {"Name"=>"FileLocationBC", "Category"=>media2_cat + "_house", "Value"=>"/opt/DIST/CableLabsFiles/dev_provider/bc/movie/#{Time.now.year}_#{Time.now.month}/#{bmid}/#{mid2_bc}/#{mid2_bc}.ats"},
                                         {"Name"=>"FileLocationHouse", "Category"=>media2_cat + "_house", "Value"=>"/opt/DIST/CableLabsFiles/dev_provider/house/movie/#{Time.now.year}_#{Time.now.month}/#{bmid}/#{mid2_house}/#{mid2_house}.ts"},
#                                          {"Name"=>"ScreenFormat", "Category"=>media2_cat + "_house", "Value"=>"HD"},
#                                          {"Name"=>"DurInSec", "Category"=>media2_cat + "_house", "Value"=>"5520"},
#                                          {"Name"=>"IPPVFlag", "Category"=>media2_cat + "_house", "Value"=>"true"},
#                                          {"Name"=>"CAFormApprovalType", "Category"=>media2_cat + "_house", "Value"=>"auto"},
                                         {"Name"=>"AudioType", "Category"=>media2_cat + "_house", "Value"=>"AC3"},
                                                              
                                        
#                                          {"Name"=>"StatusCode", "Category"=>media1_cat+ "_status_012", "Value"=>"CS_ENCRYPTION_READY"},
#                                          {"Name"=>"StatusCode", "Category"=>media2_cat+ "_status_012", "Value"=>"CS_ENCRYPTION_READY"},
                                                              
                                         {"Name"=>"StatusCode", "Category"=>media1_cat+ "_status_007", "Value"=>"CS_PPV_REQUEST_READY"},
                                         {"Name"=>"StatusCode", "Category"=>media2_cat+ "_status_007", "Value"=>"CS_PPV_REQUEST_READY"},
                                                              
                                                              
                                         {"Name"=>"StatusCode", "Category"=>"package_status_007", "Value"=>"CS_PPV_REQUEST_READY"},
                                         {"Name"=>"StatusCode", "Category"=>"package_status_012", "Value"=>"CS_ENCRYPTION_READY"}
                                         ]}}
  

  response = client.call(:process_title_package_start, message: message)
  
end


def testPTP_program_send(bmid)
    client = Savon.client(wsdl: "http://soadv.ea.intropro.com:80/soa-infra/services/Content/ProcessTitlePackage/ProcessExternalUniqueIDService?WSDL", namespace: "http://directv.com/Content/Service/ProcessExternalUniqueID")

  message = {"baseMaterialID"=>bmid, "programID"=>Time.now.sec.to_s}
  

  response = client.call(:program_id_receive, message: message)

end

def testPTP_EncrRetry(mid)
    client = Savon.client(wsdl: "http://soadv.ea.intropro.com:80/soa-infra/services/Content/ProcessTitlePackage/ProcessEncryptionService?WSDL", namespace: "http://directv.com/Content/Service/ProcessEncryption")

  message = {"materialID_house"=>mid}
  

  response = client.call(:encryption_retry_fail_status, message: message)

end
